<%@ page language="java" import="java.util.*" pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> 
 <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
 <%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/common.css" type="text/css" />
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/innerstyle.css" type="text/css" />   
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.custom.min.css" />
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script> 
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.form.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/json2.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.validate.min.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/messages_zh.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
<style type="text/css">
	.content_gridview
	{
		margin:0px;	
		padding:0px;
		width:99%;
		text-align:left;
		font-size:12px;
		border-left:#cad1dd 1px solid;
		border-top:#cad1dd 1px solid;
		border-color:"#000";
	}
	.content_gridview th
	{
		padding:0px;
		
		height:26px;
		line-height:26px;
		text-align:center;
		
		border-right:#cad1dd 1px solid;
		border-bottom:#cad1dd 1px solid;
		border-color:"#000";
		/* background-image:url(../images/th.gif); */
		background-repeat:repeat-x;
		background-position:top;
	}
	
	.content_gridview td
	{
		padding:0px;
		height:24px;
		line-height:24px;
		text-align:center;
		border-right:#cad1dd 1px solid;
		border-bottom:#cad1dd 1px solid;
		border-color:"#000";
	}
	
	.longtextbox
	{
		width:320px;
		border:#cad1dd 1px solid;
	}
	
	.textarea
	{
	    overflow:auto;	
		border:#cad1dd 1px solid;
			
	}
	
	label.error {
	color: red; /*错误信息的颜色*/
	}
	
	input.error {
		border: 1px dotted red; /*输入错误的输入框的边框样式*/
	}
</style>
<script type='text/javascript'>
	$(function(){ 
	    $("#but1").button();
	    $("#but2").button(); 
	    $("#but3").button(); 
	    jiaoyan();
	    $( "#datepicker" ).datepicker({dateFormat: 'yy-mm'});
		//为提交按钮绑定事件
	    $("#but1").click(function () {
             //$("#dialog-confirm").dialog("open");
             $( "#dialog-confirm" ).dialog({
                        resizable: false,
					    //autoOpen: false,            
						height:140,
						modal: true,
						buttons: {
							"确认": function() {
							     update();
							},
							"返回": function() {
								$( this ).dialog( "close" );
							}
						}
					}); 
          });
     });
     
   //更新
	function update(){
	   if($("#form1").valid()){ 
	        var url = "<s:url value="/hwjs"/>/updateHwjs";
	         $("#form1").ajaxSubmit({
	              url:url,
	              type:'post',
	              success:function(data){
		              var ret = eval('(' + data + ')');
		              alert(ret.msg);
		              if(ret.success==true)
		              {
		                 window.location.href="<s:url value="/hwjs"/>/directHwjflr";
		              }
	              }		              
	         });
	     }
	}
	
	//校验
	function jiaoyan()
	{
        $("#form1").validate({
	       rules: {
	       "hetbh": "required",	   
	       "jiaoshyf": "required",	  
	       "chumr": "required",	  
	       "maishr": "required",	  
	       "fahdw": "required",	  
	       "shouhdw": "required",	
	       "maifjsdw": "required",
	       "shouhfjsdw": "required",
	       "fazhmc": "required", 
	       "daozhmc": "required", 
	       "zhixdj":{
		       required: true, 
		       number:true
	       },
	       "jiaoshl":{
		       required: true, 
		       number:true
	       },
	       "yingfhk":{
		       required: true, 
		       number:true
	       },
	       "yingfyzf":{
		       number:true
	       },
	       "yingfqtfy":{
		       number:true
	       }     
	       },
		   messages: {
			   "hetbh":"必须选择相应的合同",
		       "jiaoshyf":"必须选择交收月份",
		       "chumr":"必须填写出卖人",
		       "maishr":"必须填写出卖人",
		       "fahdw":"必须填写发货单位",
		       "shouhdw":"必须填写收货单位",
		       "maifjsdw":"必须填写卖方结算单位",
		       "shouhfjsdw":"必须填写买方结算单位",
		       "fazhmc":"必须填写发站",
		       "daozhmc":"必须填写到站",
			   "zhixdj":{
			       required: "请输入执行单价", 
			       number:"请输入合法数字"
		       },
			   "jiaoshl":{
				   required:"请输入交收量",
				   number:"请输入合法数字"
			   }, 
			   "yingfhk":{
			       required: "请输入应收货款", 
			       number:"请输入合法数字"
		       },
			   "yingfyzf":{
				   number:"请输入合法数字"
			   },
			   "yingfqtfy":{
				   number:"请输入合法数字"
			   }		   
		   }
	     });
	}
	
	//打开合同
	function openHtGrid() { //单击修改链接的操作
	  openwindow('<s:url value="/hwjs"/>/openHtGrid','500','700');
	}
	
	function openwindow(url,sheight,swidth){
       var winoption ="dialogHeight:"+sheight+"px;dialogWidth:"+ swidth +"px;status:yes;scroll:yes;resizable:yes;center:yes";
       window.showModalDialog(url,window,winoption);
    }
	
	</script>
  </head>
  
 <body>
<div id="best1">
<h2><span>货物交付录入</span></h2>
<form name="form1" id="form1">
    <table id="changdi" align="center" cellpadding="0" cellspacing="0" class="content_gridview">
          <tr>
               <input type="hidden" id="sysid" name="sysid" value="${hwjf.sysid}"/>
               <td><span style="color: red;font-size:16px;vertical-align:middle;">*</span>合同号：</td>
               <td style="text-align:left"><input type="text" id="hetbh" name="hetbh" class="longtextbox" value="${hwjf.hetbh}" readonly="readonly"/>&nbsp;&nbsp;&nbsp;<a href='#' style='color:#0404bc' onclick='openHtGrid();'>选择</a></td>
               <input type="hidden" id="hetid" name="hetid"  value="${hwjf.hetid}" />
               <td><span style="color: red;font-size:16px;vertical-align:middle;">*</span>交收月份：</td>
               <td style="text-align:left"><input id="datepicker" type="text" class="longtextbox" name="jiaoshyf"  value="${hwjf.jiaoshyf}"  /></td>
          </tr>
          <tr>
               <td>出卖人：</td>
               <td style="text-align:left"><input type="text" id="chumdwmc" name="chumr" class="longtextbox" readonly="readonly"  value="${hwjf.chumr}" /></td>
               <td>买受人：</td>
               <td style="text-align:left"><input type="text" id="maisdwmc" name="maishr" class="longtextbox" readonly="readonly" value="${hwjf.maishr}" /></td>
           </tr>
           <tr>
               <td>发货单位：</td>
               <td style="text-align:left"><input type="text" id="fahdwmc" name="fahdw" class="longtextbox" readonly="readonly"  value="${hwjf.fahdw}" /></td>
               <td>收货单位：</td>
               <td style="text-align:left"><input type="text" id="shouhdwmc" name="shouhdw" class="longtextbox" readonly="readonly"  value="${hwjf.shouhdw}" /></td>
           </tr>
           <tr>
               <td><span style="color: red;font-size:16px;vertical-align:middle;">*</span>卖方结算单位：</td>
               <td style="text-align:left"><input type="text" id="chumdwjsrmc" name="maifjsdw" class="longtextbox" readonly="readonly"  value="${hwjf.maifjsdw}" /></td>
               <td><span style="color: red;font-size:16px;vertical-align:middle;">*</span>买方结算单位：</td>
               <td style="text-align:left"><input type="text" id="maisdwjsrmc" name="shouhfjsdw" class="longtextbox" readonly="readonly" value="${hwjf.shouhfjsdw}" /></td>
           </tr>
           <tr>
               <td><span style="color: red;font-size:16px;vertical-align:middle;">*</span>发站：</td>
               <td style="text-align:left"><input type="text" id="fazmch" name="fazhmc" class="longtextbox" readonly="readonly" value="${hwjf.fazhmc}" /></td>
                <input type="hidden" id="fazbm" name="fazhbm" value="${hwjf.fazhbm}" />
               <td><span style="color: red;font-size:16px;vertical-align:middle;">*</span>到站：</td>
                <input type="hidden" id="daozbm" name="daozhbm"  value="${hwjf.daozhbm}" />
               <td style="text-align:left"><input type="text" id="daozmch" name="daozhmc" class="longtextbox" readonly="readonly"  value="${hwjf.daozhmc}"  /></td>
           </tr>
            <tr>
               <td><span style="color: red;font-size:16px;vertical-align:middle;">*</span>执行单价：</td>
               <td style="text-align:left"><input type="text" name="zhixdj" class="longtextbox"  value="${hwjf.zhixdj}" /></td>
               <td><span style="color: red;font-size:16px;vertical-align:middle;">*</span>交收量：</td>
               <td style="text-align:left"><input type="text" name="jiaoshl" class="longtextbox"  value="${hwjf.jiaoshl}"  /></td>
           </tr>
           <tr>
               <td><span style="color: red;font-size:16px;vertical-align:middle;">*</span>应收货款：</td>
               <td style="text-align:left"><input type="text" name="yingfhk" class="longtextbox"  value="${hwjf.yingfhk}" /></td>
               <td>应收运杂费：</td>
               <td style="text-align:left"><input type="text" name="yingfyzf" class="longtextbox"  value="${hwjf.yingfyzf}" /></td>
           </tr>
            <tr>
               <td>应收其他费用：</td>
               <td style="text-align:left"><input type="text" name="yingfqtfy" class="longtextbox"  value="${hwjf.yingfqtfy}" /></td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
           </tr>
           <tr>
               <td>注备：</td>
               <td colspan="3" style="text-align:left"><textarea cols="110"  name="beizh" rows="6"  class="textarea" >${hwjf.beizh}</textarea></td>
           </tr>
           <tr>
		    <td colspan="4" style="text-align:right">		    
			    <input id="but1" type="button" value="保存" />&nbsp;&nbsp;&nbsp;
			    <input id="but2" type="reset" value="重置" "/>&nbsp;&nbsp;&nbsp;
			    <input id="but3" type="button" name="" value="返回" onclick="javascript:history.back();"/>
		    </td>
		    <tr>
		     <td colspan="4" style="text-align:left;">	
               <span style="color: red;font-size:12px;vertical-align:left;">
	             &nbsp;&nbsp;&nbsp;&nbsp; 使用说明：<br>
	             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1、同一份合同按照货物实际交付情况可多次录入货物交付单。<br>
	             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2、此货物交付单保存后还可以再次编辑修改，提交后不可以再进行编辑操作且数据作为统计依据。 
		       </span>
		      </td> 
           </tr>
        </tr>
     </table>
</form>
</div> 
<div id="dialog-confirm" title="是否确认保存？"></div>
  </body>
</html>
